package com.bumblebee.server.model;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
/**
 * 
 * @author Dinesh
 *
 */
@Entity
public class PurchaseItem extends AbstractEntity{

	@ManyToOne
	private Product product;
	
	@Column(nullable = false)
	private Double purchasePrice;
	
	@Column(nullable = false)
	private long purchaseQty;
	
	private BigDecimal grossAmount;

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Double getPurchasePrice() {
		return purchasePrice;
	}

	public void setPurchasePrice(Double purchasePrice) {
		this.purchasePrice = purchasePrice;
	}

	public long getPurchaseQty() {
		return purchaseQty;
	}

	public void setPurchaseQty(long purchaseQty) {
		this.purchaseQty = purchaseQty;
	}

	public BigDecimal getGrossAmount() {
		return grossAmount;
	}

	public void setGrossAmount(BigDecimal grossAmount) {
		this.grossAmount = grossAmount;
	}

	public PurchaseItem(Product product, Double purchasePrice, long purchaseQty) {
		super();
		this.product = product;
		this.purchasePrice = purchasePrice;
		this.purchaseQty = purchaseQty;
		this.grossAmount = calculatePurhcasePrice();
	}
	/**
	 * 
	 * @return
	 */
	public BigDecimal calculatePurhcasePrice(){
		return BigDecimal.valueOf(purchaseQty).multiply(BigDecimal.valueOf(purchasePrice));
	}
	
	protected PurchaseItem(){}
}
